Repository navigation
FOUR-34294 Plugins PM4 - #9125
FOUR-34294 Plugins PM4 #9125henryjonathanquispe wants to merge 31 commits into
Conversation
commit b84543b Author: AugustoLopezProcess <augusto.lopez+github@processmaker.com> Date: Tue Apr 21 08:27:15 2026 -0400 Adding plugin admin ui commit ca8a863 Author: Nolan Ehrstrom <github@nolanpro.com> Date: Mon Mar 9 11:01:46 2026 -0700 Add controllers and routes for plugin UI Copied from feature/plugins-poc-vite-ui (just without the vite/Vue3 integration) commit 3cc89bc Merge: 9e9b4aa 5da27ce Author: Nolan Ehrstrom <github@nolanpro.com> Date: Mon Mar 9 10:58:27 2026 -0700 Merge branch 'task/FOUR-28803' into feature/plugins-poc commit 9e9b4aa Author: Nolan Ehrstrom <github@nolanpro.com> Date: Mon Jan 19 12:30:54 2026 -0800 Add install command and cached routes commit 4a5df14 Author: Nolan Ehrstrom <github@nolanpro.com> Date: Wed Dec 10 09:29:20 2025 -0800 Start on plugins
Updating feature/plugins-poc-4 with last changes in develop
FOUR-32722 Some adjustments in plugins installation
…the command: php artisan horizon:terminate
FOUR-32760 After install/enable/disable a plugin, should be executed the command: php artisan horizon:terminate
…ink, add load screen-builder-form.js files from plugin
…ink, add load screen-builder-form.js files from plugin
…ink, add load screen-builder-form.js files from plugin
…ink, add load screen-builder-form.js files from plugin
PR SummaryHigh Risk Overview Requirements ( Plugins adds Reviewed by Cursor Bugbot for commit b7cbb66. Bugbot is set up for automated code reviews on this repo. Configure here. |
| } | ||
|
|
||
| try { | ||
| $zip->extractTo($tmpExtractDir); |
There was a problem hiding this comment.
Zip extract allows path escape
High Severity
ZipArchive::extractTo() writes every zip entry before plugin validation. Entries with ../ paths can overwrite files outside the temp directory, including .env or application code, even when composer.json later fails validation and the plugin is rejected.
Reviewed by Cursor Bugbot for commit 1a97475. Configure here.
| page.value = Math.floor(total / value) + 1 || 1; | ||
| } | ||
| fetch(); | ||
| }; |
There was a problem hiding this comment.
Per-page last page is off-by-one
Medium Severity
changePerPage sets the page to Math.floor(total / value) + 1 when the current page would exceed the new size. When total is an exact multiple of the new page size that becomes one past the last page, so the table shows an empty range such as 31–60 of 30.
Reviewed by Cursor Bugbot for commit 1a97475. Configure here.
| ->expectsOutput('The number of copies must be a positive integer.') | ||
| ->assertExitCode(1); | ||
| } | ||
| } |
There was a problem hiding this comment.
Unrelated duplicate-request test added
Medium Severity
This feature test invokes processmaker:duplicate-request, but that artisan command is not in this repository. The file is unrelated to plugins and will fail the console test suite whenever it runs.
Reviewed by Cursor Bugbot for commit 93a078b. Configure here.
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
This reverts commit f5e9016.
| public function uninstall(string $pluginName, ?int $userId = null): void | ||
| { | ||
| $pluginDir = storage_path('plugins'); | ||
| $pluginPath = "{$pluginDir}/{$pluginName}"; |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: MEDIUM
Description: DELETE /api/1.0/plugins/{name} forwards the raw route parameter into PluginManager::uninstall, which joins it onto storage_path('plugins') and recursively deletes that path. The route has no where() constraint, and uninstall does not reject '.', '..', or other dot segments or require the realpath to stay inside the plugins directory. For name=.. (or %2e%2e, which Laravel rawurldecodes before routing), is_dir succeeds once storage/plugins exists and deleteDirectory unlinks the parent directory: the current tenant storage root when multitenancy is on (storage/tenant_{id}), or the application storage directory when it is off. The missing artisan command is only logged; deletion runs before route-cache refresh. Toggle is not a second successful sink for '..': rename() of that parent into plugins/_.. fails because the destination is inside the source.
Impact: A caller who can pass auth:api and can:manage-plugins (or is_administrator, which Gate::before allows) can destroy the current tenant storage tree, including the local upload disk under storage/app and the default keys disk under storage/keys, instead of one plugin directory. That is other users' files and on-disk key material for the tenant, not another tenant and not code execution. The same permission can install plugin code; this path still matters because it skips plugin validation and the plugins-directory boundary with one queued request.
Remediation: Before uninstall or toggle, take the plugin name with basename, reject empty, '.', '..', slashes, and backslashes, and require realpath of the resolved directory to be a direct child of realpath(storage_path('plugins')). Do not call deleteDirectory or rename until that check passes. Abort uninstall when the plugin command cannot be run rather than continuing into deletion.
| } | ||
|
|
||
| $cleanOrigin = $this->stripEmbeddedCredentialsFromHttpUrl($canonicalRepoUrl ?? $repoUrl); | ||
| Process::path($destination)->timeout(60)->run(['git', 'remote', 'set-url', 'origin', $cleanOrigin]); |
There was a problem hiding this comment.
Reinstall drops private git credentials
Medium Severity
After clone, origin is rewritten to a credential-free URL, and updateExistingRepository now always restores a stripped origin. reinstall fetches from that origin and never reapplies GITHUB_TOKEN or the install token, so private Git plugins fail on reinstall.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 2179897. Configure here.
| } | ||
|
|
||
| $command[] = 'restart'; | ||
| $command[] = config('plugin_manager.supervisor_restart_target', 'all'); |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: MEDIUM
Description: A tenant user with manage-plugins can install, reinstall, uninstall, or toggle a plugin and thereby restart every program on the shared pod's supervisord. The job publishes a tenant-prefixed Redis reload; plugin:reload-listen, running with that tenant current, launches supervisorctl restart using plugin_manager.supervisor_restart_target, which defaults to all. .env.example does not override that default. The in-repo supervisord owns one processmaker-horizon and one processmaker-echo-server for the whole instance, and queues are tenant-aware by default, so those programs serve every co-located tenant.
Impact: On a multitenant instance, one tenant's plugin operator can repeatedly stop the shared Horizon workers and the shared echo server, plus any other program that supervisord owns (including other tenants' reload listeners). In-flight jobs and realtime notifications for co-located tenants drop. Plugin lifecycle is a tenant permission; process control of the shared supervisord is an instance-level boundary this change crosses.
Remediation: Do not default the reload action to supervisorctl restart all. Signal only the queue workers that must reload plugin code (for example horizon:terminate or queue:restart), or default supervisor_restart_target to the single queue-worker program. If a deployment is known to be one tenant per supervisord, require an explicit opt-in before restarting every program. Keep the tenant-prefixed channel, and do not let one tenant's plugin job restart programs that serve other tenants.
| public ?string $tag = null, | ||
| public ?string $zipPath = null, | ||
| public ?string $gitUsername = null, | ||
| public ?string $gitToken = null, |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: MEDIUM
Description: A Git token submitted to the plugin install API is stored on the public InstallPlugin::$gitToken property and serialized into the queue command. With multitenancy job tracking left at its default, that command is copied into the Redis hash tenant_jobs:{tenant}:{job} for 24 hours, and GET api/1.0/tenant-queues/{tenantId}/jobs/{jobId} unserializes it and returns every property. The job-details screen prints that JSON. Any is_administrator of the same tenant can read the token; QUEUE_UI_ALLOW_ALL_TENANTS (default false) is required before another tenant's administrator can.
Impact: The token is a caller-supplied Git credential used for a private clone, and this change is the first path that places it in queue state. Plugin logs and the submitting user's PluginLog broadcast run that text through redactHttpUserInfoFromString, while the tenant job hash, job-details API, and on failure the failed_jobs.payload column keep the raw token. Every administrator of the tenant can retrieve a credential the submitter entered for the clone, including a manage-plugins user who is not an administrator. The live queue copy exists until the worker finishes; the tenant hash remains for 24 hours after processing; a failed install also leaves the serialized command in failed_jobs with no expiry.
Remediation: Do not leave gitToken or gitUsername on the serialized job. Load them from a short-lived encrypted store keyed by the job id and consume that entry in handle(), and make InstallPlugin serialization drop both properties. Also omit those keys in TenantQueueController::getJobDetails and in the payload copied by trackJobByTenant so an in-flight or completed hash cannot return them. Encrypting the command with ShouldBeEncrypted protects the queue backend and failed_jobs only if the value stored and reflected is still ciphertext; pair that with the property strip so the admin job view cannot show the token.
| @@ -47,6 +48,13 @@ | |||
| use ProcessMaker\Http\Controllers\TestStatusController; | |||
|
|
|||
| Route::middleware('auth:api', 'setlocale', 'bindings', 'sanitize', 'manager')->prefix('api/1.0')->name('api.')->group(function () { | |||
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: HIGH
Description: Plugin install, reinstall, uninstall, and toggle routes were added inside the api/1.0 group that already runs the manager middleware. A non-administrator process manager who has previously received a non-empty processesIManage task page keeps the user_{id}_manager cache flag. On the later plugin request, IsManager parses can:manage-plugins from the route and writes that ability into the legacy permission cache before CustomAuthorize runs. The Gate still denies manage-plugins because it checks PermissionServiceManager, then CustomAuthorize accepts the simulated legacy list and the controller queues the plugin job.
Impact: A process manager who was not granted manage-plugins can queue installation of an attacker-controlled HTTPS repository or zip. The worker runs composer install --no-interaction in the plugin directory, so composer scripts execute as the application user, then runs the plugin artisan install command and registers the plugin service providers in the application. When the plugin reload listener is running, the same path publishes a runtime reload that schedules supervisorctl restart. That is host and application control beyond the process-manager role, and it is broader than script tasks that already execute inside the Docker script executor.
Remediation: Do not let IsManager simulate manage-plugins. Move the plugin mutation routes out of the manager middleware group, or make IsManager ignore manage-plugins (and install, uninstall, and toggle equivalents) when it builds the simulated legacy list. Authorize these routes only from a stored manage-plugins grant that CustomAuthorize cannot satisfy from the request-scoped cache.
| protected function runComposerInstall(string $pluginPath, string $repoName, ?int $userId = null): void | ||
| { | ||
| set_time_limit(0); | ||
| $process = Process::path($pluginPath) |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: HIGH
Description: A tenant administrator (is_administrator) or any principal with manage-plugins can install an arbitrary plugin from an https URL or zip. POST /api/1.0/plugins/install only checks that permission, then queues InstallPlugin in the current tenant. finishPluginSetup accepts the package when composer.json has a ProcessMaker\Plugins, ProcessMaker\Package, or ProcessMaker\Packages\ PSR-4 prefix, then runs composer install --no-interaction in the plugin directory and php artisan {folder}:install. Composer runs root-package scripts by default; --no-interaction does not disable them, and the command is not passed --no-scripts. The artisan subprocess is the same OS user and only receives TENANT. SwitchTenant isolates storage_path (storage/tenant_{id}), the database, and APP_ROUTES_CACHE. TenantsCreate creates each tenant directory with mkdir(..., 0755) and no separate uid, so the shared application user can read and write sibling tenant trees, landlord storage, and the host .env. After install, PluginServiceProvider registers extra.laravel.providers from that tree into the shared app.
Impact: On a multitenant host this gives one customer tenant admin, or anyone that tenant grants manage-plugins, code execution as the shared PHP/queue user. That identity can read and write other tenants' storage/tenant_* files and host secrets such as .env (landlord database credentials and app keys). Tenant storage and database switching do not confine the child process. Process scripts in this codebase go through the Docker script executor; plugin setup does not. The install is a single authenticated API call with a crafted zip or repository, so it is scriptable.
Remediation: Run plugin composer and artisan setup in a tenant-scoped sandbox (separate uid, chroot, or container) that cannot read other tenants' storage or host secrets such as .env. Invoke composer with --no-scripts unless the package is on an explicit allowlist. Do not register extra.laravel.providers from an unsandboxed install into the shared application process.
| ); | ||
| } | ||
|
|
||
| $loader->addPsr4($namespace, $fullPath); |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: HIGH
Description: Tenant plugin autoloaders and service providers are registered on the process-global Composer ClassLoader and the long-lived Laravel container, and nothing on the tenant switch tears them down. After a tenant with manage-plugins installs a plugin, the next tenant served by the same Octane or Horizon worker still runs that plugin's booted providers, listeners, and included autoload files.
Impact: Multitenancy is the default deployment, with one Octane (FrankenPHP) server and Horizon worker pool for every tenant hostname. A tenant operator who can call POST /api/1.0/plugins/install (can:manage-plugins) supplies the plugin composer.json and PHP. PluginServiceProvider loads it when that tenant becomes current. forgetCurrent then switches the database, storage path, and decrypted app key for the next tenant but leaves the first plugin's provider booted. Listeners, observers, and autoload-file side effects from tenant A therefore run inside tenant B's request or job, with tenant B's connection and app key already in the container. A supervisor restart after install only clears the process until the next TenantResolved for tenant A loads the plugin again. That crosses the tenant isolation boundary the switch task is supposed to enforce.
Remediation: Do not load tenant plugin code into a PHP process that will later serve another tenant. Use a worker pool pinned to one tenant, or recycle the worker on tenant switch. Removing PSR-4 prefixes alone is insufficient: already-included autoload files, loaded classes, and listeners registered in provider boot() stay in the process. SwitchTenant::forgetCurrent, Octane RequestTerminated, and the next MadeTenantCurrentEvent need a real unload path if a shared worker remains, including forgetting booted providers and the listeners they registered.
| . $fragment; | ||
| } | ||
|
|
||
| $token = env('GITHUB_TOKEN'); |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: MEDIUM
Description: Plugin install lends the worker's GITHUB_TOKEN to any caller-chosen https://github.com URL when the request omits git_username and git_token. prepareGitUrl embeds that token in the clone URL, and git clone authenticates to GitHub as the platform identity. There is no org or repository allowlist; the API only requires an https:// prefix.
Impact: A manage-plugins operator on the internet-facing API, or a process manager whose manager cache flag lets IsManager simulate can:manage-plugins, can fetch private github.com repositories that the platform token can read without knowing the token. Repositories whose composer.json PSR-4 namespace starts with ProcessMaker\Plugins, ProcessMaker\Package, or ProcessMaker\Packages\ stay under the tenant plugins directory and are then composer-installed and executed in the app. Other private repositories are deleted after validation, but the failure event sent to the operator includes the discovered PSR-4 namespaces, so the token was still used and a slice of the private tree was disclosed. Operator logs redact the token string; the credential value is not returned in the HTTP response. This is a tenant-to-platform credential boundary: the plugin operator is not the owner of GITHUB_TOKEN, and the new install path applies that identity to an arbitrary GitHub URL.
Remediation: Do not apply env('GITHUB_TOKEN') to caller-selected repositories. Require the request's own git token, or allowlist the owner/repo the platform token may clone. Pass that credential through GIT_ASKPASS or a credential helper so it is not placed in the clone URL or git remote config.
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
9c1c1e1 to
cfce9e8
Compare
| case 'view-settings': | ||
| return redirect()->route('settings.index'); | ||
| case 'view-plugins': | ||
| return redirect()->route('plugins.index'); |
There was a problem hiding this comment.
Admin landing never matches view-plugins
Low Severity
The new view-plugins redirect sits in a switch whose canAnyFirst list does not include view-plugins, so that case is unreachable. Users who only have that permission still hit the default AuthorizationException.
Reviewed by Cursor Bugbot for commit cfce9e8. Configure here.
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.
There are 12 total unresolved issues (including 9 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 041e741. Configure here.
| } | ||
| if (file_exists($zipPath)) { | ||
| unlink($zipPath); | ||
| } |
There was a problem hiding this comment.
Zip cleanup uses undefined name
Medium Severity
The installFromZip finally block passes $repoName to deleteDirectory before that variable is assigned when extractTo or early setup throws. PHP 8 then raises an ErrorException in finally, which drops the original error and skips the zip unlink.
Reviewed by Cursor Bugbot for commit 041e741. Configure here.
| public function broadcastOn() | ||
| { | ||
| return new PrivateChannel('ProcessMaker.Models.User.' . $this->userId); | ||
| } |
There was a problem hiding this comment.
Plugin logs broadcast with null user
Medium Severity
PluginLog always broadcasts on ProcessMaker.Models.User.{userId} and has no broadcastWhen. CLI install/uninstall failure events omit userId, so Echo is pushed to User. (empty id). That can error the broadcaster and never reach an operator.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 041e741. Configure here.
| public ?string $zipPath = null, | ||
| public ?string $gitUsername = null, | ||
| public ?string $gitToken = null, | ||
| ) { |
There was a problem hiding this comment.
Git tokens persist on queued jobs
Medium Severity
InstallPlugin stores gitToken and gitUsername as public constructor properties on a ShouldQueue job. Horizon/Redis payloads and failed_jobs therefore keep the operator’s git credential after the request returns, even though logs redact the same secret.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 041e741. Configure here.
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
| . $fragment; | ||
| } | ||
|
|
||
| $token = env('GITHUB_TOKEN'); |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: MEDIUM
Description: Plugin installs put a GitHub credential in the git remote URL. prepareGitUrl embeds the request git token, or env GITHUB_TOKEN when the request omits one and the URL is https://github.com/..., and cloneRepository / updateExistingRepository pass that URL to git clone and git remote set-url. Git keeps the URL in the clone process arguments for the whole clone and writes it to storage/plugins//.git/config before the later origin scrub. Those set-url calls ignore exit status, and a killed worker skips the scrub, so the credential can stay in the plugin origin. /proc//cmdline and a typical 0644 .git/config are readable by other users on the host; the environment is not. The admin API is not the leak: list() strips userinfo before returning the remote.
Impact: A same-host user who cannot read the worker environment can still capture the operator's git token or the deployment GITHUB_TOKEN while a plugin clone or fetch is running, and can read it later if the origin scrub never succeeds. That credential is the one this feature uses to fetch private plugin repositories, so disclosure gives access to whatever private GitHub content the token can read. This is limited to a host that already runs the queue worker; it does not hand the token to the repository owner. GitHub receives it only as clone authentication.
Remediation: Pass the token through a short-lived GIT_ASKPASS helper (or an equivalent credential helper) so it is not part of the remote URL, argv, or .git/config. After every clone or fetch, read origin back and fail the install if userinfo is still present. Do not fall back to the ambient GITHUB_TOKEN for an arbitrary operator-chosen github.com URL; require an explicit credential for that request.
| { | ||
| $app->forgetInstance('routes.cached'); | ||
|
|
||
| if (!$this->shouldReinitializeRouter() || !$app->routesAreCached()) { |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: HIGH
Description: On a long-lived multitenant worker, SwitchTenant::reloadRouteCache() require()s a tenant's routes-v7.php into the shared Laravel router and then leaves that compiled collection in place when a later tenant has no cache file. forgetCurrent() only clears APP_ROUTES_CACHE. Forgetting the routes.cached binding does not change what Router::dispatch() matches.
Impact: After any tenant installs, toggles, or uninstalls a plugin, route:cache writes storage/tenant_{id}/routes-v7.php and the next Octane request for that tenant loads it into the process-wide router. A later request for a tenant with no cache file is made current (database, storage, app key) and then dispatched with the previous tenant's compiled route table, including that tenant's plugin endpoints. CompiledUrlMatcher tries those routes first, so they are reachable on the victim tenant's host and run against the victim tenant's data. The cache file is Laravel's generated setCompiledRoutes payload, not arbitrary PHP; the impact is cross-tenant route dispatch, including extra or shadowing endpoints the victim did not enable.
Remediation: On every tenant switch, replace the shared route collection before serving the request. If storage/tenant_{id}/routes-v7.php exists, require it. If it does not, install a fresh RouteCollection and load the current process route map (or a landlord collection snapshotted before any tenant cache was applied). Do the same restore in forgetCurrent() so the previous compiled table cannot survive until the next makeCurrent(). Do not treat forgetInstance('routes.cached') as a router reset. Add a regression test that require()s one tenant cache, switches to a tenant with no cache file, and asserts the previous plugin route no longer matches.
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
…ce for multitenancy support
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
1 similar comment
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
|
QA server K8S was successfully deployed https://tenant-1.ci-dfa48b5e07.engk8s.processmaker.net |
|






Related Tickets & Packages
Code Review Checklist
ci:deploy
ci:k8s-branch:FOUR-34294
.